#include<bits/stdc++.h>
using namespace std;

const int SIZE = 2e5+5;
int t[SIZE<<2],a[SIZE];
int n,m;

void pushup(int i) {
	t[i]=max(t[i<<1],t[i<<1|1]);
}

void build(int i,int l,int r) {
	if(l==r) {
		t[i]=a[l];
		return;
	}
	int mid=(l+r)>>1;
	build(i<<1,l,mid);
	build(i<<1|1,mid+1,r);
	pushup(i);
}

int query(int ql,int qr,int l,int r,int i) {
	if(ql<=l && r <= qr) {
		return t[i];
	}
	int mid = (l+r)>>1;
	int result = 0;
	if(ql <= mid) {
		result = max(result,query(ql,qr,l,mid,i<<1));
	}
	if(qr > mid) {
		result = max(result,query(ql,qr,mid+1,r,i<<1|1));
	}
	return result;
}

void update(int p,int l,int r,int i,int v) {
	if(l==r) {
		if(t[i]<v) {
			t[i]=max(t[i],v);
		}
		return;
	}
	int mid=(l+r)>>1;
	if(p <= mid) {
		update(p,l,mid,i<<1,v);
	}
	if(p > mid) {
		update(p,mid+1,r,i<<1|1,v);
	}
	pushup(i);
}

void solve() {
	memset(a,0,sizeof(a));
	memset(t,0,sizeof(t));
	cin>>n>>m;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}
	build(1,1,n);
	while(m--) {
		int opt,a,b;
		cin>>opt>>a>>b;
		if(opt==2) {
			if(b<a)swap(b,a);
			cout<<query(a,b,1,n,1)<<endl;
		} else {
			update(a,1,n,1,b);
		}
	}
	return;
}

int sj()	{

	srand(time(0));
	for(int i=1; i<=49; i++) {
		char buff[114],buff2[514];
		sprintf(buff,"data/%d.in",i);
		sprintf(buff2,"data/%d.out",i);
		freopen(buff,"w",stdout);
		int n=rand()%(int(1e5))+1,m=rand()%(int(4000))+1;
		cout<<n<<' '<<m<<endl;
		for(int j=1; j<=n; j++) {
			cout<<rand()%(int(1e5))+1<<' ';
		}
		cout<<endl;
		for(int j=1; j<=m; j++) {
			int op = rand()%2+1;
			int l,r;
			if(op==1) {
				l=rand()%(int(n))+1;
				r=rand()%(int(1e5))+1;
			} else {
				l=rand()%(int(n))+1;
				r=rand()%(int(n))+1;
			}
			cout<<op<<' '<<l<<' '<<r<<endl;
		}
		fclose(stdout);
		freopen(buff2,"w",stdout);
		freopen(buff,"r",stdin);
		solve();
		fclose(stdin);
		fclose(stdout);
	}
	return 0;

}

int main(){
	solve();
}
